# Maintainer: Sven-Hendrik Haase <svenstaro@gmail.com>

# ALARM: Kevin Mihelich <kevin@archlinuxarm.org>
#  - remove makedepend on cuda

pkgname=opensubdiv
pkgver=3.4.4
pkgrel=1
pkgdesc="An Open-Source subdivision surface library"
arch=(x86_64)
url="http://graphics.pixar.com/opensubdiv"
license=('APACHE')
depends=('ptex' 'intel-tbb' 'libxcursor' 'xorg-xrandr' 'libxinerama')
makedepends=('cmake' 'doxygen' 'glfw' 'glew' 'python' 'python-pygments' 'python-docutils' 'opencl-headers')
source=("https://github.com/PixarAnimationStudios/OpenSubdiv/archive/v${pkgver//./_}.tar.gz"
        python3.patch
        cuda9.patch)
sha512sums=('fc8f28b79347015c8991150535c1339e695d96947c72fadd4fa27b546a0813c1125cd175ee03bed5aacdb3609f74c4e526ef70103d1195ba9f7df041e73ea9fb'
            '10f1f63e07d59deb4d91ba04448bb360efff0e41202bb6737caffbce09ba244efb349fe25b24880420b80fdadb268aed84923464af0d66ee1a36e4ba8f96cfd5'
            'fe51160959f71f33e3c8008158f9f98c3c7a065b22360e7719ec1d262105b35d02c2c2f64f05acee58281c938a007a88054dcc07f1aef89908e6dbf4e3e3ab6f')

prepare() {
  cd "OpenSubdiv-${pkgver//./_}"

  patch -Np1 -i "${srcdir}"/python3.patch
  patch -Np1 -i "${srcdir}"/cuda9.patch
  mkdir build
}

build() {
  cd "OpenSubdiv-${pkgver//./_}"/build

  cmake .. \
      -DCMAKE_BUILD_TYPE=Release \
      -DCMAKE_INSTALL_PREFIX=/usr

  make
}

package() {
  cd "OpenSubdiv-${pkgver//./_}"/build

  DESTDIR="$pkgdir/" make install

  rm -rf "${pkgdir}"/usr/bin
}
